<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  // var a = true;
  // var b = String( a );
  // console.log( b )
  // console.log( typeof b )
  // console.log( a )
  // console.log( typeof a )

  // 数据类型转换不影响原数据

  console.log( String( "hello" ) );
  console.log( String( 123 ) );
  console.log( String( 123.456 ) );
  console.log( String( -123.456 ) );
  console.log( String( true ) );
  console.log( String( false ) );
  console.log( String( undefined ) );
  console.log( String( null ) );
  console.log( String( function(){  } ) );

  // 花括号对象转成："[object Object]"
  console.log( String( {} ) );
  console.log( String( {name:"admin"} ) );

  // 中括号对象
  // 空数组转成空字符
  console.log( String( [] ) )
  // 有数据的数组，类似于中括号替换成引号
  console.log( String( [3,    4,    5] ) )
  console.log( String( [{}, {}] ) )
  // 数组内的null和undefined转成空字符
  console.log( String( [null, true, undefined, function(){}, NaN] ) )

  console.log("-----")


  console.log( {}.toString() );
  console.log( [].toString() );
  console.log( function(){}.toString() );
  console.log( "hello".toString() );
  console.log( (true).toString() );
  console.log( (123).toString() );
  var n = 456;
  console.log( n.toString() )
  
  // console.log( (undefined).toString() )
  // console.log( (null).toString() )



  // 利用隐式类型转换，转字符
  console.log( undefined + "" );
  


</script>
</html>